package com.zr.dao;

import com.zr.pojo.ArticleCate;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ArticleCateDao {

    @Insert("insert into ev_article_cate values (null, #{name}, #{alias}, 0)")
    int insert(ArticleCate articleCate);

//    ！排除逻辑删除的记录
    @Select("select * from ev_article_cate where is_delete = 0")
    List<ArticleCate> selectAllCate();

//      逻辑删除
    @Update("update ev_article_cate set is_delete = 1 where id = #{id}")
    int logdeleteById(int id);

//    修改文章分类
    @Update("update ev_article_cate set name = #{name}, alias = #{alias} where id = #{id} ")
    int updateById(ArticleCate articleCate);

//    根据id查询
    @Select("select * from ev_article_cate where id = #{id} and is_delete = 0")
    ArticleCate selectById(int id);



//    供新增时保证数据唯一性使用
    @Select("select * from ev_article_cate where name = #{name} and is_delete = 0")
    ArticleCate selectByName(String name);
}
